from django.db import models

# Create your models here.


class Users(models.Model):
    username = models.CharField(max_length=50)
    password = models.CharField(max_length=77)
    email = models.CharField(max_length=100,null=True)
    phone = models.CharField(max_length=11,null=True)
    sex = models.CharField(max_length=1,null=True)
    age = models.IntegerField(null=True)
    picurl = models.CharField(max_length=100,default='/static/pics/default/default.jpg')

    # 状态栏标示  0  正常  1  禁用  2 管理员  3 删除
    status = models.IntegerField(default=0)
    addtime = models.DateTimeField(auto_now_add=True)



class Types(models.Model):
    name = models.CharField(max_length=50)
    pid = models.IntegerField()
    path = models.CharField(max_length=50)



class Goods(models.Model):
    #商品所属分类
    typeid = models.ForeignKey(to="Types", to_field="id")
    # 商品标题
    title = models.CharField(max_length=255)
    # 商品价格
    price = models.DecimalField(max_digits=8, decimal_places=2)
    # 商品库存
    storage = models.IntegerField()
    # 商品图片
    pic = models.CharField(max_length=50)
    # 商品详情
    info = models.TextField()
    # 购买数量
    num  =  models.IntegerField(default=0)
    # 点击次数
    clicknum =  models.IntegerField(default=0)
    # 商品状态 1：新品、2：热销、3：下架
    status = models.IntegerField(default=1)
    # 商品添加时间
    addtime = models.DateTimeField(auto_now_add=True)